package com.zbkj.admin.pojo;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.GsonTypeHandler;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.handler.FastjsonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * 商户分红配置 实体类。
 *
 * @author mybatis-flex-helper automatic generation
 * @since 1.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@Schema(name = "商户分红配置")
@TableName(value = "eb_dividend_config")
@Table(value = "eb_dividend_config")
public class EbDividendConfigEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Schema(description = "主键")
    @Id(keyType = KeyType.Auto)
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 商户id
     */
    @Schema(description = "商户id")
    @Column(value = "mer_id")
    @TableField(value = "mer_id")
    private Long merId;

    /**
     * 比例(分红比例)
     */
    @Schema(description = "比例(分红比例)")
    @Column(value = "proportion")
    @TableField(value = "proportion")
    @DecimalMax(value = "300", message = "最小支持300%")
    @DecimalMin(value = "2", message = "最小支持2%")
    @NotNull(message = "增长比例不能为空")
    private BigDecimal proportion;

    /**
     * 拓展商户配置(统计按12小时或24小时)
     */
    @Schema(description = "拓展商户配置(统计按12小时或24小时)")
    @Column(value = "expand", typeHandler = FastjsonTypeHandler.class)
    @TableField(value = "expand", typeHandler = GsonTypeHandler.class)
    private ExpandInfo expand;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    @Column(value = "created_time")
    @TableField(value = "created_time")
    private LocalDateTime createdTime;

    /**
     * 比例计算基数(比如 200)
     */
    @Schema(description = "比例计算基数(比如 200)")
    @Column(value = "base_number")
    @TableField(value = "base_number")
    private BigDecimal baseNumber;

    /**
     * 提现手续费
     */
    @Schema(description = "提现手续费")
    @Column(value = "hand_fee")
    @TableField(value = "hand_fee")
    private BigDecimal handFee;

    /**
     * 拓展信息
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @Accessors(chain = true)
    public static class ExpandInfo implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        /**
         * 用户一级比例(单位要除100)
         */
        @Builder.Default
        @Schema(description = "用户一级比例(单位要除100)")
        private BigDecimal oneLevelProp = new BigDecimal("0.01");

        /**
         * 用户二级比例(单位要除100)
         */
        @Builder.Default
        @Schema(description = "用户二级比例(单位要除100)")
        private BigDecimal twoLevelProp = new BigDecimal("0.1");

        /**
         * 用户三级比例(单位要除100)
         */
        @Builder.Default
        @Schema(description = "用户三级比例(单位要除100)")
        private BigDecimal threeLevelProp = new BigDecimal("0.05");

        /**
         * 商品积分比例20%
         */
        @Builder.Default
        @Schema(description = "商品积分比例20%")
        private BigDecimal productProp = new BigDecimal("0.2");

    }

//    public static void main(String[] args) {
//        System.out.println(JSONUtil.toJsonStr(new ExpandInfo()));
//    }

}
